﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Manager_Nguoidung_Controls_Themquanly : System.Web.UI.UserControl
{
    BUS_Province province = new BUS_Province();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            drlProvince.DataSource = province.Province_GetByAll();
            drlProvince.DataTextField = "Name";
            drlProvince.DataValueField = "Id";
            drlProvince.DataBind();
        }
    }

    protected void btnThem_Click(object sender, EventArgs e)
    {
        DTO_Accounts obj = new DTO_Accounts();
        BUS_Accounts account = new BUS_Accounts();

        obj.UserName = txtUserName.Text;
        obj.PassWord = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPass.Text, "MD5");
        obj.FullName = txtFullName.Text;
        obj.BirthDay = string.Format("{0:G}",DateTime.Parse(txtBirthday.Text));
        if (rbNam.Checked)
        {
            obj.Sex = true;
        }
        else
        {
            obj.Sex = false;
        }
        obj.Province_Id = int.Parse(drlProvince.SelectedValue);
        obj.Address = txtDiachi.Text;
        obj.Tel = txtPhone.Text;
        obj.Mail = txtMail.Text;
        account.Accounts_Insert(obj);
        Response.Redirect("Nguoidung.aspx?action=quanly");
    }
}